define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'order/day/index' + location.search,
                    table: 'order_day',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id'),searchable:false},
                        {field: 'chu', title: __('Chu'),searchable:false},
                        {field: 'ru', title: __('Ru'),searchable:false},
                        {field: 'chunum', title: __('Chunum'),searchable:false},
                        {field: 'runum', title: __('Runum'),searchable:false},
                        {field: 'mechId', title: __('Mechid'),searchable:false},
                        {field: 'appId', title: __('Appid'),searchable:false},
                        {field: 'store_id', title: '商户', visible: true,addClass: "selectpage", extend: "data-source='auth/admin/index' data-field='nickname'"},
                        {field: 'chushouyi', title: __('Chushouyi'),searchable:false},
                        {field: 'rushouyi', title: __('Rushouyi'),searchable:false},
                        {field: 'shouyi', title: __('Shouyi'),searchable:false},
                        {field: 'daishouyi', title: __('Daishouyi'),searchable:false},
                        {field: 'jieshouyi', title: __('Jieshouyi'),searchable:false},
                        {field: 'shengshouyi', title: __('Shengshouyi'),searchable:false},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'chucharge', title: __('Chucharge'),searchable:false},
                        {field: 'pingtai_shouyi', title: __('Pingtai_shouyi'),searchable:false},
                        {field: 'pingtai_rushouyi', title: __('Pingtai_rushouyi'),searchable:false},
                        {field: 'pingtai_chushouyi', title: __('Pingtai_chushouyi'),searchable:false},
                        {field: 'rucharge', title: __('Rucharge'),searchable:false},
                        // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
